package com.sgb.kjwl.view.ui.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class DictAdapter5 extends BaseRecycleAdapter<DictEntity3> {

    private TextView nameView;
    private RelativeLayout rootLayout;
    private int type;

    public DictAdapter5(Context context, List<DictEntity3> datas) {
        super(context, R.layout.item_dict5, datas);

    }

    @Override
    public void convert(ItemViewHolder holder, final DictEntity3 entity) {
        holder.setBinding(BR.viewModel, entity);
        nameView = holder.getItem().findViewById(R.id.name_view);
        if (type == 1) {
            if ("全部".equals(entity.getName())) {
                nameView.setText(entity.getName());
            } else {
                nameView.setText(entity.getName() + "Km以内");
            }
        } else {
            nameView.setText(entity.getName());
        }
        rootLayout = holder.getItem().findViewById(R.id.root_layout);
        if (entity.isChecked()) {
            nameView.setSelected(true);
            rootLayout.setSelected(true);
        } else {
            nameView.setSelected(false);
            rootLayout.setSelected(false);
        }
    }

    public void setStringName(int type) {
        this.type = type;
    }
}
